package com.service.socket.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.service.dao.enums.CommonStatusEnums;
import com.service.dao.mapper.TradingSpotPairsMapper;
import com.service.dao.model.TradingSpotPairs;
import com.service.socket.service.TradingSpotPairsService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("tradingSpotPairsService")
public class TradingSpotPairsServiceImpl extends ServiceImpl<TradingSpotPairsMapper, TradingSpotPairs> implements TradingSpotPairsService {


    @Override
    public TradingSpotPairs getBySymbol(String symbol) {
        return getOne(new QueryWrapper<TradingSpotPairs>().lambda()
                .eq(TradingSpotPairs::getSymbol, symbol)
                .eq(TradingSpotPairs::getPairsStatus, CommonStatusEnums.ACTIVE.getCode())
                .last("limit 1"));
    }

    @Override
    public List<TradingSpotPairs> listPairs() {
        return list(new QueryWrapper<TradingSpotPairs>().lambda()
                .eq(TradingSpotPairs::getPairsStatus, CommonStatusEnums.ACTIVE.getCode()));
    }
}
